import { runCommand } from ".";

export default {
    canUndo: true,
    execute: (context, options, isUndo) => {
        runCommand(context, options, isUndo, (sheet, options) => {
            const { selections, fixedCell } = options;
            //sheet.getRange(0, 0, sheet.getRowCount(), sheet.getColumnCount()).fixed(false);
            for (let r = 0; r < sheet.getRowCount(); r++) {
                for (let c = 0; c < sheet.getColumnCount(); c++) {
                    const cell = sheet.getCell(r, c);
                    const tag = cell.tag() || {};
                    cell.tag({ ...tag, fixed:false });
                }
            }
            if (sheet.getSelections().length > 0) {
                const selection = sheet.getSelections()[0];
                sheet.getCell(selection.row, selection.col).fixed(fixedCell);
            }
        })
    }
};